package algotithm.weekendrace.leetcode225.test1;

/**
 * @author zhouyanxiang
 * @Date 2021-01-2021/1/24-10:09
 */
public class Solution {

    public static void main(String[] args) {
        Solution solution = new Solution();
        String time = "??:3?";
        String s = solution.maximumTime(time);
        System.out.println(s);
    }

    public String maximumTime(String time) {
//        String str = time.replace(":","");
        char[] str = time.toCharArray();
        for (int i = 0; i < str.length; i++) {
            if (i == 0 && str[0] == '?' && str[1] == '?') {
                str[0] = '2';
                str[1] = '3';
            }
            if (str[i] == '?' && i == 0 && str[i+1] < '4') {
                 str[i] = '2';
            } else if (str[i] == '?' &&  i == 4){
                 str[i] = '9';
            } else if (str[i] == '?' &&  (i == 1) && str[i-1] == '1' ){
                str[i] = '9';
            } else if (str[i] == '?' &&  (i == 1) && str[i-1] == '2' ){
                str[i] = '3';
            } else if (str[i] == '?' &&  (i == 3) ){
                str[i] = '5';
            } else if (str[i] == '?' &&  (i == 1) && str[i-1] == '0' ){
                str[i] = '9';
            } else if (i == 0 && str[i] == '?' && str[i+1] >= '4') {
                str[i] = '1';
            }
        }
        return String.valueOf(str);

    }
}


